﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chinaer.Model.Common;
using Chinaer.Core.Helper;

namespace Chinaer.Bll
{
    public class ShangJiaLoginDetail : Repository, Chinaer.IBll.IShangJiaLoginDetail
    {
        private static ShangJiaLoginDetail _instance = null;
        public static ShangJiaLoginDetail Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new ShangJiaLoginDetail();
                }
                return _instance;
            }
            set
            {
                _instance = value;
            }
        }
        private Chinaer.IDao.IShangJiaLoginDetailDAO shangJiaLoginDetailDAO = new Chinaer.Dao.ShangJiaLoginDetailDAO();
        public JsonResult Add(DTO.ShangJiaLoginDetailDTO t)
        {
            if (t.CheckIsNull().Success == false)
            {
                return t.CheckIsNull();
            }
            JsonResult jsonResult = new JsonResult();
            Model.Entities.Model_ShangJiaLoginDetail model_ShangJiaLoginDetail = new Model.Entities.Model_ShangJiaLoginDetail();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(t, model_ShangJiaLoginDetail);
            if (string.IsNullOrEmpty(model_ShangJiaLoginDetail.ID) || model_ShangJiaLoginDetail.ID.Trim() == "")
            {
                model_ShangJiaLoginDetail.ID = Chinaer.Core.Helper.GenerateIDHelper.GenerateID();
            }
            jsonResult.Success = shangJiaLoginDetailDAO.Add(model_ShangJiaLoginDetail);
            return jsonResult;
        }

        public JsonResult Delete(DTO.ShangJiaLoginDetailDTO t)
        {
            if (t.CheckIsNull().Success == false)
            {
                return t.CheckIsNull();
            }
            JsonResult jsonResult = new JsonResult();
            Model.Entities.Model_ShangJiaLoginDetail model_ShangJiaLoginDetail = new Model.Entities.Model_ShangJiaLoginDetail();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(t, model_ShangJiaLoginDetail);
            jsonResult.Success = shangJiaLoginDetailDAO.Delete(model_ShangJiaLoginDetail);
            return jsonResult;
        }

        public JsonResult Delete(string id)
        {
            JsonResult jsonResult = new JsonResult();
            jsonResult.Success = shangJiaLoginDetailDAO.Delete(id);
            return jsonResult;
        }

        public JsonResult Update(DTO.ShangJiaLoginDetailDTO t)
        {
            if (t.CheckIsNull().Success == false)
            {
                return t.CheckIsNull();
            }
            JsonResult jsonResult = new JsonResult();
            Model.Entities.Model_ShangJiaLoginDetail model_ShangJiaLoginDetail = new Model.Entities.Model_ShangJiaLoginDetail();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(t, model_ShangJiaLoginDetail);
            jsonResult.Success = shangJiaLoginDetailDAO.Update(model_ShangJiaLoginDetail);
            return jsonResult;
        }

        public DTO.ShangJiaLoginDetailDTO GetByID(string id)
        {
            Model.Entities.Model_ShangJiaLoginDetail model_ShangJiaLoginDetail = new Model.Entities.Model_ShangJiaLoginDetail();
            DTO.ShangJiaLoginDetailDTO shangJiaLoginDetailDTO = new DTO.ShangJiaLoginDetailDTO();
            model_ShangJiaLoginDetail = shangJiaLoginDetailDAO.GetByID(id);
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(model_ShangJiaLoginDetail, shangJiaLoginDetailDTO);
            return shangJiaLoginDetailDTO;
        }
    }
}
